#include "PhysicsBody.h"

CPhysicsBody::CPhysicsBody(void)
{
	bCollision_=false;
	bTransparent_=true;
	vecSpeed_.SetZero();
	bRemove_=true;
}

CPhysicsBody::~CPhysicsBody(void)
{
}

void CPhysicsBody::setTrasform( const b2Vec2& position, float32 angle/*=0*/ )
{
	if (pBody_)
	{
		pBody_->SetTransform(position,angle);
	}
}
void CPhysicsBody::setPhysicsBody( b2Body *pBody )
{
	pBody_=pBody;
	
}

b2Body * CPhysicsBody::getPhysicsBody()
{
	return pBody_;
}

void CPhysicsBody::update_pos( float fX,float fY )
{
	pBody_->SetTransform(b2Vec2(fX,fY),0);
}

void CPhysicsBody::posAdd( const b2Vec2& vecAdd )
{
	b2Vec2 vecPos=pBody_->GetPosition();
	vecPos.x+=vecAdd.x;
	vecPos.y+=vecAdd.y;
	pBody_->SetTransform(vecPos,0);
}

void CPhysicsBody::collisionRemove( bool bCollision )
{
	bCollision_=bCollision;
}

bool CPhysicsBody::isCollision()
{
	return bCollision_;
}

void CPhysicsBody::setPhysicsSpeed(const b2Vec2 &bvSpeed )
{
	if (pBody_)
	{
		pBody_->SetLinearVelocity(bvSpeed);
	}
}

void CPhysicsBody::setTransparent( bool bTransparent )
{
	bTransparent_=bTransparent;
}

bool CPhysicsBody::getTransparent()
{
	return bTransparent_;
}

void CPhysicsBody::setSpeed( const b2Vec2& vecSpeed )
{
	vecSpeed_=vecSpeed;
}

b2Vec2 CPhysicsBody::getSpeed()
{
	return vecSpeed_;
}

bool CPhysicsBody::canCollisionRemove()
{
	return bRemove_;
}

void CPhysicsBody::setCollisionRemove( bool bRemove )
{
	bRemove_=bRemove;
}
